
import router from '@/router'
import request from './request'

export const OpenPage = ({ url, data }: {url: string|number, data?: any}) => {
    let type = 0
    if(typeof url === 'number' && !isNaN(url)) {
        type = 1
    }
    switch(type) {
        case 0:
            router.push({ path: String(url), query: data })
            break
        case 1:
            router.go(Number(url))
            break
    }
}

export const http = {
  post: <R = any>(url:string, data?: {}): Promise<R> => {
    return request.post(url, data)
  },
  get: <R = any>(url:string, data?: {}): Promise<R> => {
    return request.get(url, data)
  },
}